/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.Login;
import model.entities.Payment;

/**
 *
 * @author Hieu.Nguyen
 */
public class PaymentDAO {
    private static PaymentDAO paymentDAO;

    public static PaymentDAO getInstance() {
        if (paymentDAO == null) {
            paymentDAO = new PaymentDAO();
        }
        return paymentDAO;
    }
    
     public List<Payment> getPayment(boolean isActived) {
        List<Payment> listPayment = new ArrayList<Payment>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblPayment";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                Payment r = new Payment();
                r.setPaymentID(rs.getInt("PaymentID"));
                r.setPaymentTypeID(rs.getInt("PaymentTypeID"));
                r.setcCNumber(rs.getInt("CCNumber"));
                r.setcCExpirationMonth(rs.getDate("CCExpirationMonth"));
                r.setcCExpirationYear(rs.getDate("CCExpirationYear"));
                r.setcCOwner(rs.getString("CCOwner"));
                r.setPaymentAmount(rs.getFloat("PaymentAmount"));
                r.setPaymentDate(rs.getDate("PaymentDate"));
                r.setReservationID(rs.getInt("ReservationID"));
                listPayment.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listPayment;
    }
    
}
